package com.wanczy.dao.proxy;

import java.sql.Connection;
import java.util.List;

import org.apache.commons.dbutils.DbUtils;

import com.wanczy.dao.RoleTableDAO;
import com.wanczy.dao.impl.RoleTableDAOImpl;
import com.wanczy.pojo.RoleTable;
import com.wanczy.util.GetDBConnection;


public class RoleTableDAOProxy implements RoleTableDAO{
	public Connection conn;
	public RoleTableDAOImpl impl = null;
	public RoleTableDAOProxy() {
		try {
			this.conn = GetDBConnection.getConnection();// 取得数据库连接
			this.impl = new RoleTableDAOImpl(this.conn);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	@Override
	public List<RoleTable> find(String name,int pageSize,int pageCurrent) {
		List<RoleTable> list = this.impl.find( name,pageSize, pageCurrent);
		DbUtils .closeQuietly(conn);
		return list;
	}
	@Override
	public boolean doUpd(RoleTable role) {
		boolean flag = this.impl.doUpd(role);
		DbUtils.commitAndCloseQuietly(conn);
		return flag;
	}
	@Override
	public boolean doIns(RoleTable role) {
		boolean flag = this.impl.doIns(role);
		DbUtils.commitAndCloseQuietly(conn);
		return flag;
	}
	@Override
	public boolean doDel(int soleId) {
		boolean flag = this.impl.doDel(soleId);
		DbUtils.commitAndCloseQuietly(conn);
		return flag;
	}
	@Override
	public List<RoleTable> findByUserId(int userId) {
		List<RoleTable> list = this.impl.findByUserId(userId);
		DbUtils .closeQuietly(conn);
		return list;
	}
	@Override
	public List<RoleTable> findByRoelId(int roleId) {
		List<RoleTable> list = this.impl.findByRoelId(roleId);
		DbUtils .closeQuietly(conn);
		return list;
	}
	@Override
	public int findCount(String name) {
		int x = this.impl.findCount(name);
		DbUtils .closeQuietly(conn);
		return x;
	} 
}
